using System.Collections.Generic;
using Triggers;
using UnityEngine;

[RequireComponent(typeof(GridTransform))]
public abstract class PointTrigger<T> : Trigger<T>
{
    private GridTransform gridTransform;

    protected virtual void Awake()
    {
        gridTransform = GetComponent<GridTransform>();
    }

    protected override List<T> CheckContact()
    {
        T target = GetContact(gridTransform.Position);
        List<T> ret = new List<T>();
        if (target != null)
            ret.Add(target);
        return ret;
    }

    protected abstract T GetContact(Vector2Int position);

    protected virtual void OnDrawGizmos()
    {
        float x = Mathf.FloorToInt(transform.position.x) + 0.5f;
        float y = Mathf.FloorToInt(transform.position.y) + 0.5f;
        Gizmos.color = Color.red;
        Gizmos.DrawWireCube(new Vector3(x, y), Vector3.one);
    }
}
